package com.twu.biblioteca;

/**
 * Created by MDH on 20/07/2014.
 */
public class BookImpl implements Book {

    private String bookTitle = "Title";
    private String bookAuthor = "Author";
    private String releaseYear = "Year";

    //Book is checked in when true and checked out when false
    private boolean checkedIn = true;

    public BookImpl(String title, String author, String releaseDate, boolean isCheckedIn) {
        bookTitle = title;
        bookAuthor = author;
        releaseYear = releaseDate;
        checkedIn = isCheckedIn;
    }

    @Override
    public String getBookTitle() {
        return bookTitle;
    }

    @Override
    public String getBookAuthor() {
        return bookAuthor;
    }

    @Override
    public String getBookYear() {
        return releaseYear;
    }

    @Override
    public boolean isCheckedIn() {
        return checkedIn;
    }

    @Override
    public String checkInBook() {
        if(isCheckedIn() == false){
            checkedIn = true;
            return "Thank you for returning your book";
        }
        return "This book is not a valid book to return";
    }

    @Override
    public String checkOutBook() {
        if(isCheckedIn() == true){
            checkedIn = false;
            return "Thank you! Enjoy the book";
        }
        return "That book is not available.";
    }

    @Override
    public void toPrint() {
        System.out.printf("%-40s %-20s %-10s \n", getBookTitle(), getBookYear(), getBookAuthor());
    }
}
